﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace FourSquareAPI
{
    public class venue
    {
        private string _id;
        private string _name;
        private decimal _distance;
        private string _address;
        private string _crossstreet;
        private decimal _geolat;
        private decimal _geolong;
        private string _phone;
        private string _twitter;
        private stats _stats;
        private List<checkin> _checkins;
        private List<tip> _tips;
        private List<string> _tags;
        private List<special> _specials;

        public venue(XmlNode Xml)
        {
            XmlNodeList xnl = Xml.ChildNodes;

            foreach (XmlNode xn in xnl)
            {
                switch (xn.Name)
                {
                    case "id":
                        this._id = xn.InnerText;
                        break;
                    case "name":
                        this._name = xn.InnerText;
                        break;
                    case "distance":
                        this._distance = Convert.ToDecimal(xn.InnerText);
                        break;
                    case "address":
                        this._address = xn.InnerText;
                        break;
                    case "crossstreet":
                        this._crossstreet = xn.InnerText;
                        break;
                    case "geolat":
                        this._geolat = Convert.ToDecimal(xn.InnerText);
                        break;
                    case "geolong":
                        this._geolong = Convert.ToDecimal(xn.InnerText);
                        break;
                    case "phone":
                        this._phone = xn.InnerText;
                        break;
                    case "twitter":
                        this._twitter = xn.InnerText;
                        break;
                    case "stats":
                        this._stats = new stats(xn);
                        break;
                    case "checkins":
                        this._checkins = new List<checkin>();
                        foreach(XmlNode xn2 in xn.ChildNodes)
                        {
                            this._checkins.Add(new checkin(xn));
                        }
                        break;
                    case "tips":
                        this._tips = new List<tip>();
                        foreach(XmlNode xn2 in xn.ChildNodes)
                        {
                            this._tips.Add(new tip(xn));
                        }
                        break;
                    case "tags":
                        this._tags = new List<string>();
                        foreach(XmlNode xn2 in xn.ChildNodes)
                        {
                            this._tags.Add(xn2.InnerText);
                        }
                        break;
                    case "specials":
                        this._specials = new List<special>();
                        foreach (XmlNode special in xn.ChildNodes)
                        {
                            this._specials.Add(new special(special));
                        }
                        break;
                }
            }
        }

        public string Id
        {
            get
            {
                return this._id;
            }
        }

        public string Name
        {
            get
            {
                return this._name;
            }
        }

        public decimal Distance
        {
            get
            {
                return this._distance;
            }
        }

        public string Address
        {
            get
            {
                return this._address;
            }
        }

        public string CrossStreet
        {
            get
            {
                return this._crossstreet;
            }
        }

        public decimal Latitude
        {
            get
            {
                return this._geolat;
            }
        }

        public decimal Longitude
        {
            get
            {
                return this._geolong;
            }
        }

        public string Phone
        {
            get
            {
                return this._phone;
            }
        }

        public string Twitter
        {
            get
            {
                return this._twitter;
            }
        }

        public stats Stats
        {
            get
            {
                return this._stats;
            }
        }

        public List<checkin> CheckIns
        {
            get
            {
                return this._checkins;
            }
        }

        public List<tip> Tips
        {
            get
            {
                return this._tips;
            }
        }

        public List<string> Tags
        {
            get
            {
                return this._tags;
            }
        }

        public List<special> Specials
        {
            get
            {
                return this._specials;
            }
        }
    }
}
